<?
include_once('conn.php');
include_once('include/func.php');
include("admin_check.php") ;
if($admin[0][2]<>10 and $admin[0][2]<>8){exit('<script>alert("您没有权限"); window.history.back(-1);</script>');}
?>	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo systemname;?></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />
	<!-- jquery packed -->
	<script type="text/javascript" src="js/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="js/dtree.js"></script>
	<!-- tableRowCheckboxToggle -->
	<script type="text/javascript" src="js/tableRowCheckboxToggle.js"></script>
    <script type="text/javascript"> 
    function fade() 
{ 
    //停留2秒后消失,在停留的时候,透明度为1.0什么都不做 
    $('<div id="add" class="quick-alert">操作成功</div>').insertAfter($("#example")).animate({opacity: 1.0}, 2000).fadeOut("slow",function(){ 
   //隐藏时把元素删除 
   $(this).remove(); 
}); 
} 
</script> 
<style>
#row1{
	background:#F3F3F3;}
</style>
<?
if(isset($_GET[add])){
	$result = $db->INSERT("INSERT INTO `".tablepre."vip` (`level`,`discount`,`scores`,`scores_limit`) VALUES ('$_POST[level]','$_POST[discount]','$_POST[scores]','$_POST[scores_limit]')");
				header("Location: $nowpage?ok");
	exit;	
	}
	//添加
if(isset($_GET[ch])){
	//print_r($_POST);
	$count_list = $db->select("SELECT vid FROM `".tablepre."vip` ");
	for($i=0;$i<count($count_list);$i++) {
		//echo $_POST['level'.$count_list[$i][0]];
		$updatedate = $db->UPDATE("UPDATE `".tablepre."vip` SET `level`='".$_POST['level'.$count_list[$i][0]]."',`discount`='".$_POST['discount'.$count_list[$i][0]]."',`scores`='".$_POST['scores'.$count_list[$i][0]]."',`scores_limit`='".$_POST['scores_limit'.$count_list[$i][0]]."' WHERE (`vid`='".$count_list[$i][0]."')");
		}
			header("Location: $nowpage?ok");
	exit;	
	}
	//修改
if(isset($_GET[del])){
	$db->DELETE("DELETE FROM `".tablepre."vip` WHERE vid ='".$_GET[del]."'");
	header("Location: $nowpage?ok");
	exit;
	}
?>
</head>
<body <? echo isset($_GET[ok])?'onload="fade();"':''; ?>>
<div id="wrap">
<div id="main" class="clearfix">
<div id="side">
  </div>
  <div id="head"><? include_once('admin_head.php');?></div>
  <div id="left"><?
  include_once('admin_menu.php');
  ?></div>
  <div id="right">
<div id="example"> </div>
<form id="form2" name="form2" method="post" action="?add">
<table width="500" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td align="right" bgcolor="#F3F3F3">等级称号</td>
    <td bgcolor="#F3F3F3"><input name="level" type="text"  /></td>
  </tr>
  <tr>
    <td align="right">等级折扣</td>
    <td><input type="text" name="discount" />
      打九点五折　就输入 95</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#F3F3F3">等级积分</td>
    <td bgcolor="#F3F3F3">每达到
      <input name="scores_limit" type="text"  size="10" />
      元，可得到
      <input name="scores" type="text"  size="10" />
      积分</td>
  </tr>
 
</table>

  <input type="submit" name="button2" id="button2" value="添加VIP" />
 
<p>
</p>
</form>
<form id="form1" name="form1" method="post" action="?ch">
  
<table width="100%" border="0">

<?
$arr_list = $db->select("SELECT * FROM `".tablepre."vip` order by vid desc");
for($i=0;$i<count($arr_list);$i++) {
	if($arr_list[$i][0]%2==0){$classcolor='id="row1"';}else{$classcolor='';}
	echo '  <tr '.$classcolor.'>
    <td><a href="?del='.$arr_list[$i][0].'" onclick="return confirm(\'确定删除? 如果此会员等级已经使用，将会导致现有数据出错！\');">[删除]</a></td>
    <td>等级称号<input type="text" name="level'.$arr_list[$i][0].'" value="'.$arr_list[$i][1].'" /></td>
<td>等级折扣<input type="text" name="discount'.$arr_list[$i][0].'" value="'.$arr_list[$i][2].'"  size="3"/></td>
<td>每达到<input type="text" name="scores_limit'.$arr_list[$i][0].'" value="'.$arr_list[$i][4].'" size="3" />元，可得到<input type="text" name="scores'.$arr_list[$i][0].'" value="'.$arr_list[$i][3].'" size="3" />积分</td>
  </tr>';
	}

?>

  <tr>
    <td><input type="submit" name="button" value="修改" /></td>
    <td>&nbsp;</td>

  </tr>
</table></form>
  </div>
  </div>
  </div>

<div id="footer">
<?
include_once('fooder.php');
?>
</div>
</BODY>
</HTML>
